package com.itheima.exerciseTest.method40_49.method49;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class Test {
    public static void main(String[] args) throws IOException {
        File file = new File("D:\\aheima\\模拟考试\\考试\\试题B\\接收文件\\1dd113cd-981b-43fd-8aaf-87a9c3019705.txt");
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
        int p = (bis.read() << 8) + bis.read();
        bis.close();
        String code = null;
        switch (p) {
            case 0xefbb:
                code = "UTF-8";
                break;
            case 0xfffe:
                code = "Unicode";
                break;
            case 0xfeff:
                code = "UTF-16BE";
                break;
            default:
                code = "GBK";
        }
        System.out.println(code);
    }
}
